package org.arabidopsis.ahocorasick;

import java.util.ArrayList;


class Queue {
    ArrayList<State> l1 = new ArrayList();
    ArrayList<State> l2 = new ArrayList();


    public void add(State s) {
        this.l2.add(s);
    }

    public boolean isEmpty() {
        return (this.l1.isEmpty() && this.l2.isEmpty());
    }

    public State pop() {
        if (isEmpty())
            throw new IllegalStateException();
        if (this.l1.isEmpty()) {
            for (int i = this.l2.size() - 1; i >= 0; i--) {
                this.l1.add(this.l2.remove(i));
            }
        }

        return this.l1.remove(this.l1.size() - 1);
    }
}